package fun.hijklmn.magic.resource.client.api;

import fun.hijklmn.magic.resource.common.transport.UploadFileRequest;
import fun.hijklmn.magic.resource.common.transport.UploadFileResponse;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.multipart.MultipartFile;

/**
 * @Description
 * @Author fs
 * @Date 2021/5/26 21:08
 * @Version 0.0.1-SNAPSHOT
 **/
@FeignClient(name = "resource-server")
public interface ResourceUploadServiceApi {

    @PutMapping(value = "upload", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
    UploadFileResponse upload(UploadFileRequest uploadFileRequest);

    @PostMapping(value = "uploadFile", consumes = MediaType.MULTIPART_FORM_DATA_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
    UploadFileResponse uploadFile(@RequestParam("key") String key, @RequestParam("fileName") String fileName, @RequestPart("file") MultipartFile file);

}
